package com.moorror.codegenvel.common.tree.actions;

import com.moorror.codegenvel.common.tree.MTTreeCell;
import com.moorror.codegenvel.common.tree.TreePanelMark;
import com.moorror.codegenvel.utils.GuiUtils;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.function.BiConsumer;

/**
 * @Author jiyanghuang
 * @Date 2025/8/18 07:57
 */
public class TransferCallbackTreeSelectAction extends AbstractMTTreeCellSelectTreeAction {

    private BiConsumer<DefaultMutableTreeNode, TreePanelMark> biConsumer;

    public TransferCallbackTreeSelectAction(TreePanelMark treePanelMark, @Nullable String text, @Nullable String description) {
        super(text, description, GuiUtils.S_SQLITE, treePanelMark);
    }

    public TransferCallbackTreeSelectAction(TreePanelMark treePanelMark, @Nullable String text, @Nullable String description, Icon icon, BiConsumer<DefaultMutableTreeNode, TreePanelMark> biConsumer) {
        super(text, description, icon, treePanelMark);
        this.biConsumer = biConsumer;
    }

    @Override
    public void handleSelectTree(DefaultMutableTreeNode mutableTreeNode, MTTreeCell mtTreeCell) {
        if(null != biConsumer){
            biConsumer.accept(mutableTreeNode, treePanelMark);
        }
    }
}
